import os
root_dir = '/home/zhangqiang/userdata/wangzeyuan/Dynamic/Dynamic.Generation/archive/success/'
protein_list = os.listdir(root_dir)
for protein in protein_list:
    dynamic_path = os.path.join(root_dir, protein, 'dynamic.pdb')
    with open(dynamic_path, 'r') as f_in:
        lines = f_in.readlines()
    new_lines = [line for line in lines if line.strip() != 'END']
    new_lines += ['END\n']
    with open(dynamic_path, 'w') as f_out:
        f_out.writelines(new_lines)
    